package com.t01.bdqn.design.proxy.dynamic;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class MethodInterceptorImpl implements MethodInterceptor {


    //拦截方法，增加自己额外的处理
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {

        before();
        //调用正常的方法执行
        Object result = methodProxy.invokeSuper(o,objects);


        return result;
    }

    public void before(){
        System.out.println("打印日志");
    }

}
